﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using CNotebook;
using CNotebook.Inventory;

namespace NotebookS2
{
    public partial class BRW_TRANSFER : RibbonForm
    {
        public BRW_TRANSFER()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }

        void BindWarehouse()
        {
            WarehouseManager oManager = new WarehouseManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            DataTable _table = oManager.GetWarehouse();

            oManager.Close();

            cboWarehouse.DataSource = _table;
            cboWarehouse.DisplayMember = "Dscription";
            cboWarehouse.ValueMember = "Code";

            cboWarehouse.Refresh();
        }

        private void BRW_TRANSFER_Load(object sender, EventArgs e)
        {
            BindWarehouse();
        }

        public void PrintPreview()
        {
            if (!gridControl1.IsPrintingAvailable)
            {
                MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error");
                return;
            }
            // Opens the Preview window. 
            gridControl1.ShowPrintPreview();
        }
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                WTManager oManager = new WTManager();
                oManager.ConnectionString = this.ConnectionString;
                oManager.Open();

                DataTable _table = oManager.GetWarehouseStatus(cboWarehouse.SelectedValue.ToString(), (DateTime)dtFROM.EditValue, (DateTime)dtTO.EditValue);
                oManager.Close();

                gridControl1.DataSource = _table;
                gridControl1.Refresh();
            }
            catch
            {
            }
        }
    }
}
